package simulator;

import java.util.HashMap;

public class Event {
	public enum EventType {
		Start, Failure, Recovered, LatentDefect, ScrubStart, ScrubComplete, End
	}
	
	private final EventType type;
	private final double time;
	private final Unit unit;
	private HashMap<String, Object> attributes;
	
	public Event(EventType type, double time, Unit unit){
		this.type = type;
		this.time = time;
		this.unit = unit;
	}
	
	public EventType getType(){
		return type;
	}
	
	public double getTime(){
		return time;
	}
	
	public Unit getUnit(){
		return unit;
	}
	
	public Object getAttribute(String key){
		if(attributes==null)
			return null;
		return attributes.get(key);
	}
	
	public void setAttribute(String key, Object value){
		if(attributes==null)
			attributes = new HashMap<String, Object>();
		attributes.put(key, value);
	}
	
	@Override
	public String toString(){
		return time+" "+unit+" "+type;
	}
}
